/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.rest.front;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.system.bo.req.QztySubmitReq;
import me.zhengjie.modules.system.domain.DccQunzhongtianyan;
import me.zhengjie.modules.system.domain.DccUser;
import me.zhengjie.modules.system.service.DccQunzhongtianyanService;
import me.zhengjie.modules.system.service.DccUserService;
import me.zhengjie.modules.system.service.dto.DccUserDto;
import me.zhengjie.modules.system.service.dto.DccUserQueryCriteria;
import me.zhengjie.utils.RedisUtils;
import me.zhengjie.utils.SmsAliUtils;
import me.zhengjie.utils.StringUtils;
import me.zhengjie.utils.bo.MllSms;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
* @website https://eladmin.vip
* @author cjl
* @date 2023-05-16
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "DCC群众天眼相关管理")
@RequestMapping("/front/qzty")
public class FrontQunzhongtianyanController {



    private final DccQunzhongtianyanService dccQunzhongtianyanService;

    private final RedisUtils redisUtils;



    @Log("群众天眼提交")
    @ApiOperation("群众天眼提交")
    @AnonymousAccess
    @PostMapping(value = "/submit")
    public ResponseEntity<Object> submit(@RequestBody QztySubmitReq qztySubmitReq) throws IOException {
        if (!StpUtil.isLogin()){
            return new ResponseEntity<>(null,HttpStatus.UNAUTHORIZED);
        }

        DccQunzhongtianyan dccQunzhongtianyan=new DccQunzhongtianyan();
        BeanUtil.copyProperties(qztySubmitReq,dccQunzhongtianyan);
        dccQunzhongtianyan.setStatus(0);
        dccQunzhongtianyan.setOperator(StpUtil.getLoginId()+"");
        dccQunzhongtianyan.setCreatedAt(new Timestamp(System.currentTimeMillis()));
        dccQunzhongtianyan.setUpdatedAt(new Timestamp(System.currentTimeMillis()));
        dccQunzhongtianyanService.create(dccQunzhongtianyan);
        return new ResponseEntity<>("提交成功",HttpStatus.OK);
    }





}